public class test {
    //蓝桥杯 分解质因数(⭐)
    public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            //在此输入您的代码...
            int a = in.nextInt();
            int b = in.nextInt();
            for(int i = a;i <= b;i++){
                decide(i);
            }
            in.close();
        }
        public static void decide(int n){
            System.out.print(n + "=");
            if(n < 2){
                System.out.print(n);
            }
            for(int i = 2;(i*i) <= n;i++){
                while(n % i == 0){
                    System.out.print(i);
                    n /= i;
                    if(n != 1){
                        System.out.print("*");
                    }
                }
            }
            if(n != 1){
                System.out.print(n);
            }
            System.out.println();
        }
    }
    //蓝桥杯 分割(⭐⭐⭐)
    public class Main2 {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            long w = in.nextInt();
            long h = in.nextInt();
            // 1. 保证正方形面积总和等于大长方体面积
            // 2. 保证 (a % 宽 == 0) && (b % 宽 == 0)
            long l = gcd(w,h);
            long r = 0;
            for(long i = 2;i <= l;i++){
                if(w % i == 0 && h % i == 0){
                    r = i;
                    break;
                }
            }
            System.out.println(r == 0 ? 0 : (w * h) / (r * r));
        }
        public static long gcd(long a,long b){
            return b == 0 ? a : gcd(b,a % b);
        }
    }
    //蓝桥杯 岛屿的数量(⭐⭐)
    public class Main {
        public static int[] dx = {0,0,1,-1};
        public static int[] dy = {1,-1,0,0};
        public static boolean[][] count;
        public static int[][] nums;
        public static int row;
        public static int col;

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            //在此输入您的代码...
            int n = in.nextInt();
            int num = 0;
            row = n;col = n;
            nums = new int[n][n];
            count = new boolean[n][n];
            for(int i = 0;i < row;i++){
                for(int j = 0;j < col;j++){
                    nums[i][j] = in.nextInt();
                }
            }
            for(int i = 0;i < row;i++){
                for(int j = 0;j < col;j++){
                    if(nums[i][j] == 1 && !count[i][j]){
                        bfs(i,j);
                        num++;
                    }
                }
            }
            System.out.println(num);
            in.close();
        }
        //x,y代表当前位置
        public static void bfs(int nx,int ny){
            Queue<int[]> queue = new LinkedList<>();
            queue.add(new int[]{nx,ny});
            while(!queue.isEmpty()){
                int[] t = queue.poll();
                for(int i = 0;i < 4;i++){
                    int x = t[0] + dx[i];
                    int y = t[1] + dy[i];
                    if(x >= 0 && x < row && y >= 0 && y < col && !count[x][y] && nums[x][y] == 1){
                        count[x][y] = true;
                        queue.add(new int[]{x,y});
                    }
                }
            }
        }
    }
}
